﻿using System.Windows;

namespace AiMoWindows.Windows.InputString
{
    /// <summary>
    /// InputStringDialog.xaml 的交互逻辑
    /// </summary>
    partial class InputStringDialog : Window
    {
        readonly InputStringViewModel m_ViewModel;
        public string TitleEN { get; }
        public string TitleCN { get; }
        public string LabelEN { get; }
        public string LabelCN { get; }
        public InputStringDialog(string titleEN, string titleCN, string labelEN, string labelCN, string defaultText)
        {
            TitleEN = titleEN;
            TitleCN = titleCN;
            LabelEN = labelEN;
            LabelCN = labelCN;
            m_ViewModel = new InputStringViewModel(this)
            {
                InputStringText = defaultText
            };
            DataContext = m_ViewModel;
            InitializeComponent();
        }

        public string UserInputString => m_ViewModel.InputStringText.Trim();


        private void Cancel_Button_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
        private void OK_Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(UserInputString))
            {
                DialogResult = true;
                Close();
            }
            else
            {
                MessageBox.Show(this, "Input String Is Empty");
            }
        }
    }
}
